<template>
    <div class="list">
        <Row>
            <Col :xs="24">
                <div class="margin-up-down">
                    <Button type="info" @click="goAdd" class="abs-right">
                        <i
                            class="iconfont icon-add"
                            style="font-size: 14px; margin-right: 5px"
                        ></i>
                    </Button>
                </div>
                <div class="margin-up-down">
                    <Input
                        v-model="searchKey"
                        placeholder="请输入医疗团队名称"
                        style="width: 200px; margin: 0 10px"
                    />
                </div>
                <div class="margin-up-down">
                    <Button
                        type="primary"
                        icon="ios-search"
                        @click="search"
                    ></Button>
                </div>
            </Col>
        </Row>
        <Table stripe :columns="columns1" :data="doctorList"></Table>
        <div class="page">
            <Page
                :total="count"
                :current="pageNo"
                :pageSize="pageSize"
                show-total
                show-elevator
                @on-change="pageChange"
            />
        </div>
    </div>
</template>
<script>
import api from "@/api/commonApi";
export default {
    data() {
        return {
            province: null,
            city: null,
            area: null,
            hospital: null,
            isBack: 1,
            searchKey: "",
            pageNo: 1,
            pageSize: 10,
            count: 10,
            columns1: [
                {
                    title: "排序",
                    align: "center",
                    key: "sum",
                    width: 60,
                    render: (h, params) => {
                        let sum =
                            (this.pageNo - 1) * this.pageSize +
                            params.index +
                            1;
                        return h("span", sum);
                    },
                },
                {
                    title: "所属医院",
                    align: "center",
                    key: "hospitalName",
                    // width:150
                },
                {
                    title: "科室",
                    align: "center",
                    key: "deptName",
                    // width:120
                },
                {
                    title: "医疗团队名称",
                    align: "center",
                    key: "name",
                    // width:150
                },
                {
                    title: "团队类型",
                    align: "center",
                    key: "type",
                    // width:150
                },
                {
                    title: "团队负责人",
                    align: "center",
                    key: "doctorName",
                    // width:120
                },
                {
                    title: "团队电话",
                    align: "center",
                    key: "phone",
                    // width:120
                },
                {
                    title: "团队人数",
                    align: "center",
                    key: "teamNum",
                    // width:100
                },
                // {
                //     title:"团队签约数",
                //     align:"center",
                //     key:"teamSigningNum",
                //     // width:110
                // },
                {
                    title: "设置",
                    align: "center",
                    fixed: "right",
                    width: 120,
                    render: (h, params) => {
                        let id = params.row.id;
                        return [
                            h(
                                "a",
                                {
                                    attrs: {
                                        href: "javascript:void(0);",
                                    },
                                    on: {
                                        click: () => {
                                            this.functionJS.queryNavgationTo(
                                                this,
                                                "/index/doctorOperation/doctorGroup/review",
                                                {
                                                    pageNo: this.pageNo,
                                                    province: this.province,
                                                    city: this.city,
                                                    area: this.area,
                                                    hospital: this.hospital,
                                                    isBack: 2,
                                                    id: id,
                                                }
                                            );
                                        },
                                    },
                                },
                                "查看"
                            ),
                            " | ",
                            h(
                                "a",
                                {
                                    attrs: {
                                        href: "javascript:void(0);",
                                    },
                                    on: {
                                        click: () => {
                                            this.functionJS.queryNavgationTo(
                                                this,
                                                "/index/doctorOperation/doctorGroup/edit",
                                                {
                                                    pageNo: this.pageNo,
                                                    province: this.province,
                                                    city: this.city,
                                                    area: this.area,
                                                    hospital: this.hospital,
                                                    isBack: 2,
                                                    id: id,
                                                }
                                            );
                                        },
                                    },
                                },
                                "编辑"
                            ),
                        ];
                    },
                },
            ],
            doctorList: [],
        };
    },
    created() {
        this.province = this.$route.query.province
            ? parseInt(this.$route.query.province)
            : null;
        this.city = this.$route.query.city
            ? parseInt(this.$route.query.city)
            : null;
        this.area = this.$route.query.area
            ? parseInt(this.$route.query.area)
            : null;
        this.hospital = this.$route.query.hospital
            ? this.$route.query.hospital
            : null;
        this.isBack = this.$route.query.isBack
            ? parseInt(this.$route.query.isBack)
            : 1;
        let breadList = [
            { path: "/index", title: "首页" },
            {
                path: "/index/operation/doctorManagement/index",
                title: "医生端运营",
            },
            {
                path: "/index/operation/docrorGroup",
                title: "医疗小组",
            },
        ];
        this.$emit("changeBreadList", breadList);
    },
    mounted() {
        this.loadDoctorGroup(this.pageNo);
    },
    methods: {
        changeProvince(val) {
            this.province = val;
        },
        changeCity(val) {
            this.city = val;
        },
        changeArea(val) {
            this.area = val;
        },
        changeHospital(val) {
            this.hospital = val;
        },
        // 添加新小组
        goAdd() {
            this.functionJS.queryNavgationTo(
                this,
                "/index/doctorOperation/doctorGroup/add",
                {
                    pageNo: this.pageNo,
                    province: this.province,
                    city: this.city,
                    area: this.area,
                    hospital: this.hospital,
                    isBack: 2,
                }
            );
        },
        // 分布页码改变
        pageChange(index) {
            this.loadDoctorGroup(index);
        },
        // 关键字查询
        search() {
            this.loadDoctorGroup(1);
        },
        //医生小组管理-分页列表
        loadDoctorGroup(pageNo) {
            this.pageNo = pageNo;
            var params = {};
            params.provinceCode = this.province ? this.province : null;
            params.cityCode = this.city ? this.city : null;
            params.areaCode = this.area ? this.area : null;
            params.hospitalId = this.hospital ? this.hospital : null;
            params.searchKey = this.searchKey ? this.searchKey : null;
            params.pageNo = pageNo;
            params.pageSize = this.pageSize;
            this.$axios.post(api.findTeamDtoList, params).then((res) => {
                console.log(res);
                if (res.data.success) {
                    let ret = res.data.object;
                    this.count = ret.total;
                    if (ret.records) {
                        ret.records.forEach((item, index) => {
                            item.sum = this.addZeros(index);
                            item.type =
                                item.type == 1
                                    ? "家医签约团队"
                                    : "出院随访签约团队";
                        });
                        this.doctorList = ret.records;
                    } else {
                        this.doctorList = [];
                    }
                }
            });
        },
    },
};
</script>
<style lang="less" scoped>
.list {
    padding: 10px;
    width: 100%;
    background: #ffffff;
    box-sizing: border-box;
    header {
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-bottom: 10px;
    }
    .margin-up-down {
        display: inline-block;
        margin: 10px 0;
    }
    .page {
        text-align: center;
        margin-top: 20px;
    }
}
</style>
